<?php 
    $link = "tin-tuc";
    $limit = 4;
    $tins = $t->ListTin(-1,-1);
    $total_record = mysql_num_rows($tins);
    $total_record = ($total_record > 60) ? 60 : $total_record;
    $total_page = ceil($total_record/$limit);
    $offset = $limit * ($page - 1);
    $rs = $t->ListTin($offset,$limit);
    $page_show=5;  
?>

<div class="motopress-wrapper content-holder clearfix">
    <div class="container">
        <div class="row">
            <div class="span12" data-motopress-wrapper-type="content">
                <div class="row">
                    <div class="span12" data-motopress-type="static">
                        <section class="title-section">
                            <ul class="breadcrumb breadcrumb__t"><li><a href="http://<?php echo $_SERVER['SERVER_NAME']; ?>">Trang chủ</a></li> <li class="divider">/</li> <li class="active">Tin tức</li></ul>  
                        </section>  
                    </div>
                </div>
                <div class="row">
                    <div class="span8 right" id="content" data-motopress-type="loop">
                        <?php 
                        while($row = mysql_fetch_assoc($rs)){
                        ?>
                        <article id="post-71" class="post-71 post type-post status-publish format-standard hentry category-aenean-nonummy-hendrerit tag-tellus post__holder cat-41-id">
                            <header class="post-header">
                                <h2 class="post-title"><a href="detail/<?php echo $row['TieuDe_KD']."-".$row['idTin'];?>.html" title="<?php echo $row['TieuDe'];?>"><?php echo $row['TieuDe'];?></a></h2>
                            </header>
                            <figure class="featured-thumbnail thumbnail"><a href="detail/<?php echo $row['TieuDe_KD']."-".$row['idTin'];?>.html">
                                    <img width="250" height="200" src="<?php echo str_replace("../","",$row['UrlHinh']); ?>" class="attachment-post-thumbnail wp-post-image" alt="<?php echo $row['TieuDe'];?>">
                                </a>
                            </figure>

                            <div class="post_content">
                                <div class="excerpt">
                                    <?php echo $row['TomTat'];?>                                    
                                </div>
                                <a href="detail/<?php echo $row['TieuDe_KD']."-".$row['idTin'];?>.html" class="btn btn-primary btn-large">Chi tiết</a>
                                <div class="clear"></div>
                            </div>

                            <div class="post_meta">
                                <span class="post_category"><span class="post_date"><i class="icon-calendar"></i><time datetime="<?php echo date('d-m-Y H:i',$row['Ngay']);?>"><?php echo date('d-m-Y',$row['Ngay']);?></time></span><span class="post_author"><i class="icon-user"></i><a href="#" title="Posts by admin" rel="author">admin</a></span>
                                    <span class="post_comment"><i class="icon-comments"></i>
                                        <a href="#" class="comments-link" title="<?php echo $row['TieuDe'];?>">No comments</a></span>
                                
                            </div>

                        </article>
                        <?php } ?>                     
                        <?php echo $t->phantrang2($page,$page_show,$total_page,$link);?>
                    </div>
                    <div class="span4 sidebar" id="sidebar" data-motopress-type="static-sidebar">
                        <div id="categories-2" class="widget"><h3>Giới thiệu</h3>
                             <ul>
                                <li class="cat-item cat-item-41"><a href="gioi-thieu.html">Về chúng tôi</a> </li>
                                <li class="cat-item cat-item-41"><a href="tai-sao-can-thiet-ke-web.html">Tại sao cần thiết kế website ?</a> </li>
                                <li class="cat-item cat-item-44"><a href="bang-bao-gia-thiet-ke-web.html">Bảng báo giá thiết kế web</a> </li>                                
                            </ul>
                        </div>                        
                        <div id="my_postwidget-2" class="widget"> <h3>Xem nhiều</h3>
                            <ul class="post-list unstyled">
                                <?php 
                                $tin_ngaunhien = $t->TinNgauNhien();
                               while($row_ngaunhien = mysql_fetch_assoc($tin_ngaunhien)){
                                ?>
                                <li class="post-list_li clearfix">
                                    <figure class="featured-thumbnail thumbnail">
                                        <a href="detail/<?php echo $row_ngaunhien['TieuDe_KD']."-".$row_ngaunhien['idTin'];?>.html" title="<?php echo $row_ngaunhien['TieuDe'];?>">
                                            <img width="120" height="120" src="<?php echo str_replace("../","",$row_ngaunhien['UrlHinh']); ?>" alt="<?php echo $row_ngaunhien['TieuDe'];?>">
                                        </a>
                                    </figure>
                                    <time datetime="<?php echo date('d-m-Y H:i',$row_ngaunhien['Ngay']);?>"><?php echo date('d-m-Y',$row_ngaunhien['Ngay']);?></time>
                                    <h4 class="post-list_h">
                                        <a href="" rel="bookmark" title="<?php echo $row_ngaunhien['TieuDe'];?>">
                                            <?php echo $row_ngaunhien['TieuDe'];?>
                                        </a>
                                    </h4>
                                    <div class="excerpt">
                                        <?php echo $row_ngaunhien['TomTat'];?></div>
                                    <a href="detail/<?php echo $row_ngaunhien['TieuDe_KD']."-".$row_ngaunhien['idTin'];?>.html" class="btn btn-primary">Chi tiết</a>
                                </li>                               
                               <?php } ?>
                            </ul>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>